package com.shoppingmall.controller;

import com.shoppingmall.commons.Result;
import com.shoppingmall.model.UserInfo;
import com.shoppingmall.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RegisterController {
    @Autowired
    private UserService userService;
    @PostMapping("/register")
    public Result register(@RequestBody UserInfo userInfo){
        try {
            userService.register(userInfo);
            return Result.success("注册成功");
        } catch (Exception e) {
            System.out.println("用户名已存在异常");
        }

        return Result.fail(500,"用户名已存在!");
    }


}
